package com.action.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * <p>
 * <p>
 * </p>
 *
 * @author stylefeng123
 * @since 2018-03-25
 */
public class Redpacket implements Parcelable {

    private static final long serialVersionUID = 1L;
    public static final Integer STATUS_ORDER_PAYED = 1;

    private Long id;
    /**
     * 发红包的注释
     */
    private String content;
    /**
     * 红包数量
     */
    private Integer num;
    /**
     * 红包金额
     */
    private BigDecimal account;
    /**
     * 红包的经度
     */
    private Double lng;
    /**
     * 红包的维度
     */
    private Double lat;
    /**
     * 发红包的人的用户Id
     */
    private Long senderId;
    private String wxOrder;
    private Integer status;
    /**
     * 红包的订单号
     */
    private String sn;
    /**
     * 红包类型 0 普通红包  1 广告红包
     */
    private Integer type;
    /**
     * -3 全国 -2 全省 -1 全市 0 区/县 1 1km , 3 3km, 5 5km, 10 10km
     */
    private Integer range;
    /**
     * 发红包的平台 0 app  1 pc  2 小程序
     */
    private Integer platform;
    /**
     * 更新时间
     */
    private String updateAt;
    /**
     * 创建时间
     */
    private String createdAt;
    private String geoCode;
    private Integer consumeNum;

    private String wxNickname;
    private String wxIcon;
    private String holdMoney;
    private String userPrice;
    private int recvCount;
    private int commentCount;
    private String imgs;
    private int pwdInputCount;
    private String userPercent;
    private String userTotalMoney;
    private String url;
    private boolean selfRob;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * 这个红包是否随机过
     */
    private boolean isGlobalRandomed;

    public boolean isGlobalRandomed() {
        return isGlobalRandomed;
    }

    public void setGlobalRandomed(boolean globalRandomed) {
        isGlobalRandomed = globalRandomed;
    }

    public String getUserTotalMoney() {
        return userTotalMoney;
    }

    public void setUserTotalMoney(String userTotalMoney) {
        this.userTotalMoney = userTotalMoney;
    }

    public String getUserPercent() {
        return userPercent;
    }

    public void setUserPercent(String userPercent) {
        this.userPercent = userPercent;
    }

    public int getPwdInputCount() {
        return pwdInputCount;
    }

    public String getImgs() {
        return imgs;
    }

    public void setPwdInputCount(int pwdInputCount) {
        this.pwdInputCount = pwdInputCount;
    }

    public void setImgs(String imgs) {
        this.imgs = imgs;
    }

    public int getRecvCount() {
        return recvCount;
    }

    public void setRecvCount(int recvCount) {
        this.recvCount = recvCount;
    }

    public int getCommentCount() {
        return commentCount;
    }

    public void setCommentCount(int commentCount) {
        this.commentCount = commentCount;
    }

    public String getHoldMoney() {
        return holdMoney;
    }

    public String getUserPrice() {
        return userPrice;
    }

    public void setHoldMoney(String holdPrice) {
        this.holdMoney = holdPrice;
    }

    public void setUserPrice(String userPrice) {
        this.userPrice = userPrice;
    }

    public String getWxIcon() {
        return wxIcon;
    }

    public void setWxIcon(String wxIcon) {
        this.wxIcon = wxIcon;
    }

    public String getWxNickname() {
        return wxNickname;
    }

    public void setWxNickname(String wxNickname) {
        this.wxNickname = wxNickname;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public BigDecimal getAccount() {
        return account;
    }

    public void setAccount(BigDecimal account) {
        this.account = account;
    }


    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public Long getSenderId() {
        return senderId;
    }

    public void setSenderId(Long senderId) {
        this.senderId = senderId;
    }

    public String getWxOrder() {
        return wxOrder;
    }

    public void setWxOrder(String wxOrder) {
        this.wxOrder = wxOrder;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getRange() {
        return range;
    }

    public void setRange(Integer range) {
        this.range = range;
    }

    public Integer getPlatform() {
        return platform;
    }

    public void setPlatform(Integer platform) {
        this.platform = platform;
    }

    public String getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(String updateAt) {
        this.updateAt = updateAt;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getGeoCode() {
        return geoCode;
    }

    public void setGeoCode(String geoCode) {
        this.geoCode = geoCode;
    }

    public Integer getConsumeNum() {
        return consumeNum;
    }

    public void setConsumeNum(Integer consumeNum) {
        this.consumeNum = consumeNum;
    }


    @Override
    public String toString() {
        return "Redpacket{" +
                "id=" + id +
                ", content=" + content +
                ", num=" + num +
                ", account=" + account +
                ", lng=" + lng +
                ", lat=" + lat +
                ", senderId=" + senderId +
                ", wxOrder=" + wxOrder +
                ", status=" + status +
                ", sn=" + sn +
                ", type=" + type +
                ", range=" + range +
                ", platform=" + platform +
                ", updateAt=" + updateAt +
                ", createdAt=" + createdAt +
                ", geoCode=" + geoCode +
                ", consumeNum=" + consumeNum +
                "}";
    }


    public Redpacket() {
    }


    public boolean isSelfRob() {
        return selfRob;
    }

    public void setSelfRob(boolean selfRob) {
        this.selfRob = selfRob;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Redpacket redpacket = (Redpacket) o;
        return Objects.equals(sn, redpacket.sn);
    }

    @Override
    public int hashCode() {

        return Objects.hash(sn);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.content);
        dest.writeValue(this.num);
        dest.writeSerializable(this.account);
        dest.writeValue(this.lng);
        dest.writeValue(this.lat);
        dest.writeValue(this.senderId);
        dest.writeString(this.wxOrder);
        dest.writeValue(this.status);
        dest.writeString(this.sn);
        dest.writeValue(this.type);
        dest.writeValue(this.range);
        dest.writeValue(this.platform);
        dest.writeString(this.updateAt);
        dest.writeString(this.createdAt);
        dest.writeString(this.geoCode);
        dest.writeValue(this.consumeNum);
        dest.writeString(this.wxNickname);
        dest.writeString(this.wxIcon);
        dest.writeString(this.holdMoney);
        dest.writeString(this.userPrice);
        dest.writeInt(this.recvCount);
        dest.writeInt(this.commentCount);
        dest.writeString(this.imgs);
        dest.writeInt(this.pwdInputCount);
        dest.writeString(this.userPercent);
        dest.writeString(this.userTotalMoney);
        dest.writeString(this.url);
        dest.writeByte(this.selfRob ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isGlobalRandomed ? (byte) 1 : (byte) 0);
    }

    protected Redpacket(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.content = in.readString();
        this.num = (Integer) in.readValue(Integer.class.getClassLoader());
        this.account = (BigDecimal) in.readSerializable();
        this.lng = (Double) in.readValue(Double.class.getClassLoader());
        this.lat = (Double) in.readValue(Double.class.getClassLoader());
        this.senderId = (Long) in.readValue(Long.class.getClassLoader());
        this.wxOrder = in.readString();
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.sn = in.readString();
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.range = (Integer) in.readValue(Integer.class.getClassLoader());
        this.platform = (Integer) in.readValue(Integer.class.getClassLoader());
        this.updateAt = in.readString();
        this.createdAt = in.readString();
        this.geoCode = in.readString();
        this.consumeNum = (Integer) in.readValue(Integer.class.getClassLoader());
        this.wxNickname = in.readString();
        this.wxIcon = in.readString();
        this.holdMoney = in.readString();
        this.userPrice = in.readString();
        this.recvCount = in.readInt();
        this.commentCount = in.readInt();
        this.imgs = in.readString();
        this.pwdInputCount = in.readInt();
        this.userPercent = in.readString();
        this.userTotalMoney = in.readString();
        this.url = in.readString();
        this.selfRob = in.readByte() != 0;
        this.isGlobalRandomed = in.readByte() != 0;
    }

    public static final Creator<Redpacket> CREATOR = new Creator<Redpacket>() {
        @Override
        public Redpacket createFromParcel(Parcel source) {
            return new Redpacket(source);
        }

        @Override
        public Redpacket[] newArray(int size) {
            return new Redpacket[size];
        }
    };
}
